﻿using MB.Orm.DB;
using MB.RuleBase.Common;
using Model;
using Public.DataAccess;
using System;
using System.Collections.Generic;
using System.Data.Common;


namespace Business
{
    public class BAction
    {
        public BAction() { }

        /// <summary>
        /// 获取日志信息
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="total"></param>
        /// <param name="parValues"></param>
        /// <returns></returns>
        public List<ActionInfo> GetActionInfo(int pageIndex, int pageSize, out int total, params object[] parValues)
        {
            using (var DbScope = new OperationDatabaseScope(new OperationDatabaseContext("NewWeb")))
            {
                List<ActionInfo> list = PagedDatabaseExcuteByXmlHelper.NewInstance.GetPagedObjectsByXml3<ActionInfo>
                                                ("Action", "GetActionInfo", pageIndex, pageSize, out total, parValues);
                return list;
            }
        }

        /// <summary>
        /// 获取日志类型信息
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="total"></param>
        /// <param name="parValues"></param>
        /// <returns></returns>
        public List<ActionType> GetActionTypeInfo(int pageIndex, int pageSize, out int total, params object[] parValues)
        {
            using (var DbScope = new OperationDatabaseScope(new OperationDatabaseContext("NewWeb")))
            {
                List<ActionType> list = PagedDatabaseExcuteByXmlHelper.NewInstance.GetPagedObjectsByXml3<ActionType>
                                                ("Action", "GetActionTypeInfo", pageIndex, pageSize, out total, parValues);
                return list;
            }
        }

        /// <summary>
        /// 新增日志明细
        /// </summary>
        /// <param name="location"></param>
        /// <returns></returns>
        public int AddLmActionInfo(ActionInfo lmActionInfo)
        {
            return DatabaseExcuteByXmlHelper.NewInstance.ExecuteNonQueryByEntity<ActionInfo>("Action", "AddActionInfo", lmActionInfo);
        }


        /// <summary>
        /// 新增日志类型
        /// </summary>
        /// <param name="location"></param>
        /// <returns></returns>
        public int AddLmActionTypeInfo(ActionType lmActionType)
        {
            return DatabaseExcuteByXmlHelper.NewInstance.ExecuteNonQueryByEntity<ActionType>("Action", "AddActionTypeInfo", lmActionType);
        }

        /// <summary>
        /// 查询日志编号是否存在
        /// </summary>
        /// <param name="seedType"></param>
        /// <returns></returns>
        public List<ActionType> GetActionTypeInfoByCode(int typeCode)
        {
            using (var DbScope = new OperationDatabaseScope(new OperationDatabaseContext("NewWeb")))
            {
                List<ActionType> lmWarrantyTimelist = DatabaseExcuteByXmlHelper.NewInstance.GetObjectsByXml<ActionType>("Action", "GetActionTypeInfoByCode", typeCode);
                return lmWarrantyTimelist;
            }
        }


    }
}
